<?php
class ModelAction extends CommonAction
{
	public function index()
	{
		$Model = D ( 'Model' );
		$modelList = $Model->get_modelList ();
		$this->list=$modelList;
		$this->display();
	}
	//添加
	public function add()
	{
		if ($_POST)
		{
			$Model = D ( 'Model' );
			$data = $_POST ['data'];
			var_dump($data);
			
			if ($Model->create ( $data ))
			{
				$Model->add ( $data );
			}
			$this->display();
		} else
		{
			$this->display ();
		}
	
	}
	//修改
	public function edit()
	{
		if ($_POST)
		{
			$Model = D ( 'Model' );
			$data = $_POST ['data'];
			$Model->save ( $data );
		} else
		{
			$Model = D ( 'Model' );
			$id=$this->_get('id');
			$data=$Model->find($id);
			$this->data=$data;
			$this->display ();
		}
	}
	//删除
	public function del()
	{
		if ($this->isGet)
		{
			$Model = D ( 'Model' );
			$id = $_GET['id'];
			$Model->delete ( $id );
			$message='删除成功';
			$jumpurl=$_SERVER["HTTP_REFERER"];
			$this->success($message,$jumpurl);
		}
	}
	//批量删除
	public function delAll()
	{
		if ($this->isPost)
		{
			$Model = D ( 'Model' );
			$ids = $_POST ['ids'];
			
			$Model->delete ( $id );
		}
	}
}
?>